import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '所属部门',
    align:"center",
    dataIndex: 'sysOrgCode_dictText'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'username'
   },
   {
    title: '性别',
    align:"center",
    dataIndex: 'sex_dictText'
   },
   {
    title: '身份证号',
    align:"center",
    dataIndex: 'idCard'
   },
   {
    title: '人脸图像',
    align:"center",
    dataIndex: 'faceImg',
    customRender:render.renderImage,
   },
   {
    title: '电话',
    align:"center",
    dataIndex: 'phone'
   },
   {
    title: '工号',
    align:"center",
    dataIndex: 'workNo'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "姓名",
      field: 'username',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "性别",
      field: 'sex',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"sex"
      },
      //colProps: {span: 6},
 	},
	{
      label: "身份证号",
      field: 'idCard',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "电话",
      field: 'phone',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "工号",
      field: 'workNo',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '所属部门',
    field: 'sysOrgCode',
     component: 'JSelectDept',
  },
  {
    label: '姓名',
    field: 'username',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入姓名!'},
          ];
     },
  },
  {
    label: '性别',
    field: 'sex',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"sex"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入性别!'},
          ];
     },
  },
  {
    label: '身份证号',
    field: 'idCard',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                //  { pattern: '/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/', message: '不符合校验规则!'},
          ];
     },
  },
  {
    label: '人脸图像',
    field: 'faceImg',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 0
      },
  },
  {
    label: '电话',
    field: 'phone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '工号',
    field: 'workNo',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  sysOrgCode: {title: '所属部门',order: 0,view: 'sel_depart', type: 'string',},
  username: {title: '姓名',order: 1,view: 'text', type: 'string',},
  sex: {title: '性别',order: 2,view: 'number', type: 'number',dictCode: 'sex',},
  idCard: {title: '身份证号',order: 3,view: 'text', type: 'string',},
  faceImg: {title: '人脸图像',order: 4,view: 'image', type: 'string',},
  phone: {title: '电话',order: 5,view: 'text', type: 'string',},
  workNo: {title: '工号',order: 6,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}